#!/bin/sh
if [ $# != 4 ]
then
   echo "Usage: make_menu_list.sh kernelName UUID Search_path output_file"
   exit -1;
fi
kernelName=$1
uuid=$2
search_path=$3
output_file=$4

#echo $search_path
vmlinuz="vmlinuz"
initrd="initrd"
vmlinuz=`find $search_path \( -name vmlinuz* \) -type f -print`
#echo $vmlinuz
initrd=`find $search_path \( -name initrd* \) -type f -print`
echo $initrd
vmlinuz=`echo $vmlinuz | awk ' BEGIN{FS="/" } { print $NF; } '`
initrd=`echo $initrd | awk ' BEGIN{FS="/" } { print $NF; } '`
#echo $vmlinuz
#echo $initrd
cat >"$output_file" <<EOF
default=0
timeout=5
title $kernelName
root (hd0,0)
kernel /boot/$vmlinuz root=UUID=$uuid ro quiet
initrd /boot/$initrd


title $kernelName (single-user mode)
root (hd0,0)
kernel /boot/$vmlinuz root=UUID=$uuid ro single
initrd /boot/$initrd
EOF
